//
//  LookPlayerBottomer.m
//  PigMarket
//
//  Created by 张敬 on 2019/9/3.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "LookPlayerBottomer.h"

@interface LookPlayerBottomer()

@end


@implementation LookPlayerBottomer

#pragma mark - lifecycle methods

- (void)setupUI
{
    self.backgroundColor = KBlackColor;
    self.userInteractionEnabled = YES;
    
    [self addSubview:self.switchIcon];
    [self addSubview:self.switchPigIcon];
    [self addSubview:self.voiceIcon];
    [self addSubview:self.cameraIcon];
    [self addSubview:self.qualityLab];
    [self addSubview:self.wholeScreenIcon];
    
}


- (void)layoutSubviews{
    [super layoutSubviews];
    
    self.height = 40;
    
    CGFloat gap = (KScreenWidth - 20  - 40 *6)/5.0;
    _switchIcon.size = _wholeScreenIcon.size = _cameraIcon.size = _switchPigIcon.size = _voiceIcon.size = CGSizeMake(40, 40);
    _switchIcon.mj_y = _wholeScreenIcon.mj_y = _cameraIcon.mj_y = _switchPigIcon.mj_y = _voiceIcon.mj_y = 0;
    _switchIcon.mj_x = 10;
    _cameraIcon.mj_x = _switchIcon.right + gap;
    _voiceIcon.mj_x = _cameraIcon.right + gap;
    _switchPigIcon.mj_x = _voiceIcon.right + gap;
    _wholeScreenIcon.mj_x = KScreenWidth - _wholeScreenIcon.width - 10;
    
    _qualityLab.size = CGSizeMake(30, 16);
    _qualityLab.mj_y = (40 - _qualityLab.height)/2.0;
    _qualityLab.mj_x = _switchPigIcon.right + gap;
    
}

#pragma mark - setter methods
#pragma mark - getter methods

- (UIImageView *)switchIcon{
    
    if (!_switchIcon) {
        _switchIcon = [UIImageView makeImageByImageName:@"look_play_stop" cornerRadius:0];
        _switchIcon.isNeedAnimation = YES;
        
        @weakify(self);
        _switchIcon.tapBlock = ^{
            @strongify(self);
            
            if (self.dealPlayBlock) {
                self.dealPlayBlock();
            }
        };
        
    }
    return _switchIcon;
}

- (UIImageView *)cameraIcon{
    
    if (!_cameraIcon) {
        _cameraIcon = [UIImageView makeImageByImageName:@"look_morePlayer" cornerRadius:0];
        _cameraIcon.isNeedAnimation = YES;

        
        @weakify(self);
        _cameraIcon.tapBlock = ^{
            @strongify(self);
            
            if (self.dealCameraBlock) {
                self.dealCameraBlock();
            }
        };

    }
    return _cameraIcon;
}

- (UIImageView *)wholeScreenIcon{
    
    if (!_wholeScreenIcon) {
        _wholeScreenIcon = [UIImageView makeImageByImageName:@"look_whole" cornerRadius:0];
        _wholeScreenIcon.isNeedAnimation = YES;
        
        @weakify(self);
        _wholeScreenIcon.tapBlock = ^{
            @strongify(self);
            
            if (self.dealWholePlayBlock) {
                self.dealWholePlayBlock();
            }
        };

    }
    return _wholeScreenIcon;
}

- (UIImageView *)switchPigIcon{
    
    if (!_switchPigIcon) {
        _switchPigIcon = [UIImageView makeImageByImageName:@"look_switchPig" cornerRadius:0];
        _switchPigIcon.isNeedAnimation = YES;

        @weakify(self);
        _switchPigIcon.tapBlock = ^{
            @strongify(self);
            
            if (self.dealSwitchPigBlock) {
                self.dealSwitchPigBlock();
            }
        };

    }
    return _switchPigIcon;
}

- (UIImageView *)voiceIcon{
    
    if (!_voiceIcon) {
        _voiceIcon = [UIImageView makeImageByImageName:@"look_voice_have" cornerRadius:0];
        _voiceIcon.isNeedAnimation = YES;

        @weakify(self);
        _voiceIcon.tapBlock = ^{
            @strongify(self);
            
            if (self.dealVoiceBlock) {
                self.dealVoiceBlock();
            }
        };

    }
    return _voiceIcon;
}

- (UILabel *)qualityLab{
    
    if (!_qualityLab) {
        _qualityLab = [UILabel makeLabelWithText:@"流畅" textColor:UIColorFromRGB(0xE4E6E8) font:mFont(11) textAliment:1];
        _qualityLab.layer.borderColor = UIColorFromRGB(0xE4E6E8).CGColor;
        _qualityLab.layer.borderWidth = 1;
        [self addShadowAndCircleCorner:_qualityLab.layer corner:3];
        _qualityLab.isNeedAnimation = YES;

        
        @weakify(self);
        _qualityLab.tapBlock = ^{
            @strongify(self);
            
            if (self.dealQualityBlock) {
                self.dealQualityBlock();
            }
        };

    }
    return _qualityLab;
}


@end
